// 导入 express 模块
import express from "express";
import cors from "cors";
import { run } from "./src/db/index";
import "./src/hooks/taskSocket/index";
import { useRedis } from "./src/hooks/useRedis/index";
import { useRouter } from "./src/index";
import bodyParser from "body-parser";
import dotenv from "dotenv";

const app = express();

async function basicsInit() {
  dotenv.config();
  run()
    .then(() => {
      app.use(bodyParser.urlencoded({ extended: false }));
      // 解析json格式的表单数据
      app.use(bodyParser.json());
      app.use(cors());
      useRouter(app);
      useRedis();


      
    })
    .catch(console.dir);
}

basicsInit();

export default app;
